package com.reader.cms.service.impl.content;


import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.reader.cms.entity.content.ReaderPictureContent;
import com.reader.cms.mapper.content.ReaderPictureContentMapper;
import com.reader.cms.service.content.IReaderPictureContentService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author gumenghao
 * @@description 服务实现类
 * @date 2018-11-02
 */
@Service
@Transactional
public class ReaderPictureContentServiceImpl extends ServiceImpl<ReaderPictureContentMapper, ReaderPictureContent> implements IReaderPictureContentService {


    @Autowired
    private ReaderPictureContentMapper readerPictureContentMapper;

    /**
     * @param currentPage 当前页
     * @param size        每页显示条数
     * @param state
     * @param rangeDate   @return
     * @function 多表关联查询
     */
    @Transactional(readOnly = true)
    @Override
    public Page<ReaderPictureContent> selectListPage(int currentPage, int size, String state, String[] rangeDate) {
        Page<ReaderPictureContent> page = new Page<>(currentPage, size);// 当前页，总条数 构造 page 对象
        String startDate = null;
        String endDate = null;
        if (rangeDate !=null && rangeDate.length != 0) {
            startDate = rangeDate[0];
            endDate = rangeDate[1];
        }
        return page.setRecords(readerPictureContentMapper.selectListPage(page,state,startDate,endDate));
    }

}